package com.kgcx.order.service;

import java.sql.Timestamp;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kgcx.common.eum.CommonDataEeum;
import com.kgcx.order.domain.PayAccount;
import com.kgcx.order.mapper.PayAccountMapper;
import com.kgcx.order.rabbitmq.PayAccountProducer;
/**
 * 公司支付信息
 * @author qinze
 *
 */
@Service
public class PayAccountService {

	@Resource
	private PayAccountMapper payAccountMapper;
	@Resource
	private PayAccountProducer payAccountProducer;

	@Transactional(rollbackFor = Exception.class)
	public void insertPayAccount(PayAccount payAccount) {
		payAccount.setCreateTime(new Timestamp(System.currentTimeMillis()));
		payAccount.setUpdateTime(new Timestamp(System.currentTimeMillis()));
		payAccount.setState(0);
		payAccount.setStatus(CommonDataEeum.DATA_STATE_NORMAL.getCode());
		payAccountMapper.insertPayAccount(payAccount);
		payAccountProducer.insertPayAccountProducer(payAccount);
	}
	/**
     * 根据ID查询公司支付信息放到MQ里面给监管平台
     * @param kid
     * @return
     */
    public PayAccount getPayAccount(Long kid) {
        PayAccount payAccount =payAccountMapper.selectByPrimaryKey(kid);
        payAccountProducer.insertPayAccountProducer(payAccount);
      return  payAccount;
    }
}
